fix(ci): run PR automation via pull_request_target for fork PRs#169
Open
jmeridth wants to merge 1 commit into
Open
fix(ci): run PR automation via pull_request_target for fork PRs#169jmeridth wants to merge 1 commit into
jmeridth wants to merge 1 commit into
Conversation
The auto-author-assign and mark-ready-when-ready workflows trigger on pull_request, so PRs from forks get a read-only GITHUB_TOKEN and both jobs fail (assignees API denied; contents: write denied). Switch both to pull_request_target, which runs in the base-repo context with a read-write token even for fork PRs. This is safe because neither workflow checks out or executes PR-head code. Both actions operate purely on the event payload (PR number, draft flag, labels, head SHA) via the API, so the base-repo context evaluates no untrusted code. ## What/Why Auto-assign and auto-mark-ready silently fail on every external fork PR because pull_request gives forks a read-only token; pull_request_target restores a read-write token without executing fork code. ## Proof it works actionlint and pre-commit pass. Verified kenyonj/mark-ready-when-ready reads github.event.pull_request.head.sha (not github.sha) and toshimaru/auto-author-assign acts via the assignees API, so neither depends on a PR-head checkout. ## Risk + AI role Low. CI-only. Edits drafted with Claude Opus 4.8, reviewed by a human. The main review concern is confirming neither workflow ever adds a PR-code checkout in future edits, which would turn pull_request_target into a pwn-request vector. ## Review focus Whether pull_request_target is acceptable here versus gating the jobs to skip on fork PRs (which would drop the feature for external contributors instead). Signed-off-by: jmeridth <jmeridth@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
The
auto-author-assignandmark-ready-when-readyworkflows trigger onpull_request. For PRs from forks, GitHub caps theGITHUB_TOKENat read-only regardless of the declaredpermissions:block, so both jobs fail:auto-author-assign:Resource not accessible by integrationon the assignees API.mark-ready-when-ready:Token is missing required permissions: contents: write.This switches both to
pull_request_target, which runs in the base-repo context and receives a read-write token even for fork PRs.This is safe because neither workflow checks out or executes PR-head code:
pull_request_targetruns the workflow definition from the base branch, so a fork PR cannot alter these workflows to abuse the elevated token.toshimaru/auto-author-assignassigns the author purely via the API from the event payload.kenyonj/mark-ready-when-readyreads the PR number, draft flag, labels, andhead.shafrom the event payload (verified it usesgithub.event.pull_request.head.sha, notgithub.sha) and acts only viagh api.No checkout step exists in either workflow, so there is no untrusted code execution.
Verification
actionlintand the repo'spre-commithooks pass on both files.Readiness Checklist
Author/Contributor